//
//  firstViewController.m
//  weiAai
//
//  Created by ibokan on 14-12-16.
//  Copyright (c) 2014年 ibokan. All rights reserved.
//

#import "firstViewController.h"
#import "AFNetworking.h"
@interface firstViewController ()

@end

@implementation firstViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"firstcontroller");
	[self setupfirst];
    [self tianjia];
}
-(void)tianjia
{
    UITextField *textFie =[[UITextField alloc]init];
    textFie.frame =CGRectMake(100, 100, 80, 30);
    textFie.backgroundColor =[UIColor redColor];
    textFie.placeholder =@"name";
    [self.view addSubview:textFie];
    
    UITextField  *t = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 80, 30)];
    [self.view addSubview:t];
    
   UITextField *textFi =[[UITextField alloc]init];
   textFie.frame =CGRectMake(100, 170, 80, 30);
    textFie.backgroundColor =[UIColor redColor];
    textFie.placeholder =@"sex";
    [self.view addSubview:textFi];

    UIImageView *iamge =[[UIImageView alloc]init];
    iamge.frame =CGRectMake(10, 200, 100, 100);
   iamge.backgroundColor =[UIColor redColor];
    [self.view addSubview:iamge];


    UIButton *button =[[UIButton alloc]init];

    button.frame =CGRectMake(200, 200, 90, 30);
    [button setTitle:@"保存" forState:UIControlStateNormal];
    button.backgroundColor =[UIColor redColor];
    [button addTarget:self action:@selector(baocun) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];


}

-(void)baocun
{
    AFHTTPRequestOperationManager *manger =[AFHTTPRequestOperationManager manager];
    
    NSMutableDictionary *dic =[NSMutableDictionary dictionary];
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    // dic[@"client_id"]=@"4236150992";
    // dic[@"client_secret"]=@"17e7a0c2381ba6e6c7b9bb7bf020620c";
    //  dic[@"grant_type"]=@"authorization_code";
    // dic[@"code"]=code;
    //  dic[@"redirect_uri"]=@"http://www.baidu.com";
    NSString *token = [[NSUserDefaults standardUserDefaults]objectForKey:@"access_token"];
    NSString *uid = [[NSUserDefaults standardUserDefaults]objectForKey:@"userID"];
    dic[@"uid"] =uid;
    dic[@"access_token"] =token;
    [manger POST:@"http://lovemyqq.sinaapp.com/setUser.php" parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"%@",responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error);
    }];
    

}
-(void)setupfirst
{
    }

@end
